package blogsys.demo.utils;

/**
 * 返回响应体工具
 * 2022.5.14
 * @author xp
 * @version 1.0
 */
public class ResultUtils {
    /**
     * 成功
     * @return
     */
    public static JsonResult success() {
        return new JsonResult(true);
    }

    public static JsonResult success(ResultCode resultEnum) {
        return new JsonResult(true,resultEnum);
    }

    public static <T> JsonResult<T> success(T data) {
        return new JsonResult(true, data);
    }

    public static <T> JsonResult<T> success(ResultCode resultEnum,T data){
        return new JsonResult<>(true,resultEnum,data);
    }


    /**
     * 失败
     * @return
     */
    public static JsonResult fail() {
        return new JsonResult(false);
    }

    public static JsonResult fail(ResultCode resultEnum) {
        return new JsonResult(false, resultEnum);
    }
}
